<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <!--[if IE]>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <![endif]-->
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Page title -->
    <title>Petz - Pet HTML5 Template</title>
    <!--[if lt IE 9]>
    <script src="${pageContext.request.contextPath}/foreground/js/respond.js"></script>
    <![endif]-->
    <!-- Bootstrap Core CSS -->
    <link href="${pageContext.request.contextPath}/foreground/css/bootstrap.css" rel="stylesheet" type="text/css">
    <!-- Icon fonts -->
    <link href="${pageContext.request.contextPath}/foreground/fonts/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="${pageContext.request.contextPath}/foreground/fonts/flaticons/flaticon.css" rel="stylesheet" type="text/css">
    <link href="${pageContext.request.contextPath}/foreground/fonts/glyphicons/bootstrap-glyphicons.css" rel="stylesheet" type="text/css">
    <!-- Google fonts -->
    <link href="https://fonts.googleapis.com/css?family=Lato:400,800" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Baloo+Thambi" rel="stylesheet">
    <!-- Style CSS -->
    <link href="${pageContext.request.contextPath}/foreground/css/style.css" rel="stylesheet">
    <!-- Plugins CSS -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/foreground/css/plugins.css">
    <!-- Color Style CSS -->
    <link href="${pageContext.request.contextPath}/foreground/styles/maincolors.css" rel="stylesheet">

    <script src="${pageContext.request.contextPath}/background/js/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/background/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/background/js/xadmin.js"></script>

</head>
<body>
<%--导航栏--%>
<%@ include file="../common/topbar.jsp" %>


<section id="adoption" class="pages">
    <div class="jumbotron" data-stellar-background-ratio="0.5">
        <div class="jumbo-heading" data-stellar-background-ratio="1.2">
            <h1>领养</h1>
        </div>
    </div>

    <div class="container margin1">
        <div class="row">
            <div class="col-md-5">
                <img src="${animal.anPicture}" class="center-block img-rounded img-responsive" alt="">
            </div>
            <div class="col-md-7 res-margin">
                <h3>${animal.anName}</h3>
                <div class="pet-adopt-info">
                    <h6>编号ID: ${animal.anId}</h6>
                    <h6>年龄: ${animal.anAge}</h6>
                </div>
                <p>${animal.anFormation}
                </p>
                <ul class="custom no-margin">
                    <li>如果您领养了它，它将成为您最好的朋友</li>
                    <li>希望您可以好好对待它</li>
                    <li>祝你们相处愉快</li>
                </ul>
                <button onclick="adoptAnimal(${animal.anId})" class="btn">领养</button>
            </div>
        </div>
    </div>
</section>
<script>
    function adoptAnimal(anId){
        layer.confirm('确认要领养吗？',function(index){
            //发异步删除数据
            $.ajax({
                url:"addAdapterAuditing",
                data:{"anId":anId},//servlet按照"classobj_id"取值
                type:"POST",
                success:function(data){//从servlet获取返回数据data:{SUCCESS ERREO}
                    if(data=="Login"){
                        layer.confirm('您还未登录，是否现在去登录？',function(index){
                            window.location.href = 'user-login'; //跳转页面路径;
                        })

                    }else if(data=="SUCCESS"){//如果数据库返回说明删除成功
                        layer.msg('已提交管理员审核，请耐心等待!',{icon:1,time:1000});
                    }else if(data=="Exist"){
                        layer.msg('您有审核未通过的领养申请，请耐心等待管理员审核通过！',{icon:1,time:5000});
                    }else{
                        layer.alert(data,{title:"提交失败"});
                    }
                }
            });
        });
    }
</script>
</body>
</html>
